<template>
  <div class="tab-container">
    <el-card shadow="never">
      <el-tabs v-model="activeName" @tab-click="tabClick">
        <tab-pane  ></tab-pane>
      </el-tabs>
    </el-card>
    <slide-panel ref='slidepanel'></slide-panel>
  </div>  
</template>

<script>
import tabPane from './components/TXPane'
import { fetchCount } from '@/api/order'

export default {
  name: 'tab',
  components: { tabPane },
  data() {
    return {
      orderCount: {
        'all': 58,
        'pending_payment': 20,
        'pending_delivery': 10,
        'shipped': 10,
        'completed': 10,
        'close': 15
      },
      tabMapOptions: [
        { label: '全部', key: 'all' },
        { label: '待付款', key: 'pending_payment' },
        { label: '待发货', key: 'pending_delivery' },
        { label: '已发货', key: 'shipped' },
        { label: '已完成', key: 'completed' },
        { label: '已关闭', key: 'close' }
      ],
      activeName: 'all',
      createdTimes: 0,
      slidePanelshow: false
    }
  },
  created() {
    this.orderCountStatus()
    // setTimeout(() => {
    //   this.orderCount.all = 100
    //   this.$notify({
    //     title: '注意',
    //     message: '你有新的订单需要处理',
    //     type: 'warning'
    //   })
    // }, 1000)
  },
  computed: {
  },
  methods: {
    orderCountStatus() {
      fetchCount({}).then(res => {
        this.orderCount.all = res.data.all
        this.orderCount.pending_payment = res.data.pending_payment
        this.orderCount.pending_delivery = res.data.pending_delivery
        this.orderCount.shipped = res.data.shipped
        this.orderCount.completed = res.data.completed
        this.orderCount.close = res.data.close
      }).catch(err => {
        console.log(err)
      })
    },
    tabLabel(tab) {
      return tab.label + '（' + this.orderCount[tab.key] + '）'
    },
    // 显示侧边栏，订单详细信息
    showSlidePanel(id) {
      this.$refs.slidepanel.$emit('show', id)
    },
    tabClick() {
      this.orderCountStatus()
    }
  }
}
</script>
<style lang="scss" scoped>
.tab-container{
  margin: 10px;
}
.slidepanel-box {
  display: table;
  margin-top: 8px;
  font-size: 14px;
  .slidepanel-box-left ,
  .slidepanel-box-right {
    display: table-cell;
    vertical-align: top;
    text-align: left;
    img {
      border-radius: 0px;
      max-width: 80px;
    }
  }
  .slidepanel-box-left {
    padding-right: 8px;
  }
  .slidepanel-box-right {
    width: 10000px;
    overflow: hidden;
    line-height: 1.45;
    .p-item-sub {
      color: #76838f;
    }
    .p-dec {
      float: right;
      padding-right: 10px;
      font-size: 12px;
      text-align: right;
      color: #888;
      p {
        line-height: 1;
        margin: 0;
      }
    }
  }
}
</style>